import GameUI from "../../game/GameUI";
import { AdManager } from "../ads/AdManager";
import { EVENT_NAME_ENUM } from "../base/EnumIndex";
import { AudioManager1 } from "../manager/AudioManager1";
import { EventManager } from "../manager/EventManager";
import { UIManager } from "../manager/UIManager";

const { ccclass, property } = cc._decorator;
@ccclass
export default class douyinPropUI extends cc.Component {
    @property({ type: cc.Button, displayName: "领取奖励" })
    getBtn: cc.Button = null;
    @property({ type: cc.Button, displayName: "去领取奖励" })
    getToBtn: cc.Button = null;

    @property({ type: cc.Node, displayName: "说明" })
    infoNode: cc.Node = null;
    @property({ type: cc.Node, displayName: "已领取" })
    getSpr: cc.Node = null;

    isGet: boolean = false;

    onLoad() {
        cc.log("douyinPropUI onLoad");
        this.showDesc();
        AdManager.isFromSideBar(() => this.showReward());
    }
    start() {
        this.getBtn.node.on("click", () => {
            EventManager.ins.emit(EVENT_NAME_ENUM.HIDE_GIFT_BTN);
            AdManager.fuFang();
            this.node.destroy();
        });

        this.getToBtn.node.on("click", () => {
            AdManager.navigateToScene(() => this.showReward())
        });
        this.node.on("click", () => {
            this.node.destroy();
        });
    }

    showReward() {
        cc.log("showReward");
        this.getSpr.active = true;
        this.infoNode.active = false;
        this.getBtn.node.active = true;
        this.getToBtn.node.active = false;
    }
    showDesc() {
        cc.log("showDesc");
        this.getSpr.active = false;
        this.infoNode.active = true;
        this.getBtn.node.active = false;
        this.getToBtn.node.active = true;
    }
    // update (dt) {}


    clickBtnClose() {
        // AudioManager1.playClick();
        // UIManager.ins.close();
        this.node.destroy();
    }


}
